// Grid Columns
function grid_column($atts, $content=null, $shortcodename =""){
extract(shortcode_atts(array(
'class' => ''
), $atts));
// Initialize return variable
$return = '';
//remove wrong nested
$content = remove_invalid_tags($content, array('p'));
// add divs to the content
$return .= '
';
$return .= do_shortcode($content);
$return .= '
';
return $return;
}
add_shortcode('grid_1', 'grid_column');
add_shortcode('grid_2', 'grid_column');
add_shortcode('grid_3', 'grid_column');
add_shortcode('grid_4', 'grid_column');
add_shortcode('grid_5', 'grid_column');
add_shortcode('grid_6', 'grid_column');
add_shortcode('grid_7', 'grid_column');
add_shortcode('grid_8', 'grid_column');
add_shortcode('grid_9', 'grid_column');
add_shortcode('grid_10', 'grid_column');
add_shortcode('grid_11', 'grid_column');
add_shortcode('grid_12', 'grid_column');
// Fluid Columns
function fluid_column($atts, $content=null, $shortcodename =""){
$last = '';
if (isset($atts[0]) && trim($atts[0]) == 'last') $last = 'last';
// Initialize return variable
$return = '';
//remove wrong nested
$content = remove_invalid_tags($content, array('p'));
// add divs to the content
$return .= '
';
$return .= do_shortcode($content);
$return .= '
';
if($last != '') {
$return .= '';
}
return $return;
}
add_shortcode('one_half', 'fluid_column');
add_shortcode('one_third', 'fluid_column');
add_shortcode('two_third', 'fluid_column');
add_shortcode('one_fourth', 'fluid_column');
add_shortcode('three_fourth', 'fluid_column');
add_shortcode('one_fifth', 'fluid_column');
add_shortcode('two_fifth', 'fluid_column');
add_shortcode('three_fifth', 'fluid_column');
add_shortcode('four_fifth', 'fluid_column');
add_shortcode('one_sixth', 'fluid_column');
add_shortcode('five_sixth', 'fluid_column');
//Recent Posts
function shortcode_recent_posts($atts, $content = null) {
extract(shortcode_atts(array(
'type' => 'post',
'category' => '',
'custom_category' => '',
'post_format' => 'standard',
'num' => '5',
'meta' => 'true',
'thumb' => 'true',
'thumb_width' => '120',
'thumb_height' => '120',
'more_text_single' => '',
'excerpt_count' => '0',
'custom_class' => ''
), $atts));
$output = '';
global $post;
global $my_string_limit_words;
if($post_format == 'standard') {
$args = array(
'post_type' => $type,
'category_name' => $category,
$type . '_category' => $custom_category,
'numberposts' => $num,
'orderby' => 'post_date',
'order' => 'DESC',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array('post-format-aside', 'post-format-gallery', 'post-format-link', 'post-format-image', 'post-format-quote', 'post-format-audio', 'post-format-video'),
'operator' => 'NOT IN'
)
)
);
} else {
$args = array(
'post_type' => $type,
'category_name' => $category,
$type . '_category' => $custom_category,
'numberposts' => $num,
'orderby' => 'post_date',
'order' => 'DESC',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array('post-format-' . $post_format)
)
)
);
}
$latest = get_posts($args);
foreach($latest as $post) {
setup_postdata($post);
$excerpt = get_the_excerpt($post->ID);
$attachment_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
$url = $attachment_url['0'];
$image = aq_resize($url, $thumb_width, $thumb_height, true);
$post_classes = get_post_class();
foreach ($post_classes as $key => $value) {
$pos = strripos($value, 'tag-');
if ($pos !== false) {
unset($post_classes[$i]);
}
}
$post_classes= implode(' ', $post_classes);
$output .= '- ';
//Aside
if($post_format == "aside") {
$output .= the_content($post->ID);
//Link
} elseif ($post_format == "link") {
$url = get_post_meta(get_the_ID(), 'tz_link_url', true);
$output .= '';
$output .= get_the_title($post->ID);
$output .= '';
//Quote
} elseif ($post_format == "quote") {
$quote = get_post_meta(get_the_ID(), 'tz_quote', true);
$output .= '
';
$output .= '
';
$output .= $quote;
$output .= '
';
$output .= '
';
//Image
} elseif ($post_format == "image") {
if (has_post_thumbnail() ):
$lightbox = get_post_meta(get_the_ID(), 'tz_image_lightbox', TRUE);
$src = wp_get_attachment_image_src( get_post_thumbnail_id(get_the_ID()), array( '9999','9999' ), false, '' );
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'full'); //get img URL
$image = aq_resize( $img_url, 200, 120, true ); //resize & crop img
$output .= '';
$output .= '';
$output .= '
';
$output .= '';
$output .= '';
endif;
//Audio
} elseif ($post_format == "audio") {
$audio = get_post_meta(get_the_ID(), 'tz_audio_mp3', true);
$output .= '';
$output .= '
';
$output .= '
';
$output .= '';
$output .= get_the_content($post->ID);
$output .= '
';
//Video
} elseif ($post_format == "video") {
$embed = get_post_meta(get_the_ID(), 'tz_video_embed', TRUE);
$output .= '';
$output .= stripslashes(htmlspecialchars_decode($embed));
$output .= '';
if($excerpt_count >= 1){
$output .= '';
$output .= my_string_limit_words($excerpt,$excerpt_count);
$output .= '
';
}
//Standard
} else {
if ($thumb == 'true') {
if ( has_post_thumbnail($post->ID) ){
$output .= '';
$output .= '
';
$output .= '';
}
}
if($meta == 'true'){
$output .= '';
$output .= '';
$output .= '';
$output .= get_the_time( 'd' );
$output .= '';
$output .= get_the_time( 'M' );
$output .= '';
$output .= '';
}
$output .= '';
if($more_text_single!=""){
$output .= '';
$output .= $more_text_single;
$output .= '';
}
}
$output .= '';
$output .= ' ';
}
$output .= '
';
return $output;
}
add_shortcode('recent_posts', 'shortcode_recent_posts');
// Recent Comments
function shortcode_recent_comments($atts, $content = null) {
extract(shortcode_atts(array(
'num' => '5'
), $atts));
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
comment_post_ID, comment_author, comment_author_email, comment_date_gmt, comment_approved,
comment_type,comment_author_url,
SUBSTRING(comment_content,1,50) AS com_excerpt
FROM $wpdb->comments
LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
$wpdb->posts.ID)
WHERE comment_approved = '1' AND comment_type = '' AND
post_password = ''
ORDER BY comment_date_gmt DESC LIMIT ".$num;
$comments = $wpdb->get_results($sql);
$output = '';
return $output;
}
add_shortcode('recent_comments', 'shortcode_recent_comments');
//Popular Posts
function shortcode_popular_posts($atts, $content = null) {
extract(shortcode_atts(array(
'num' => '5'
), $atts));
$args = array(
'numberposts' => $num,
'orderby' => 'comment_count',
'order' => 'DESC',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array('post-format-aside', 'post-format-gallery', 'post-format-link', 'post-format-image', 'post-format-quote', 'post-format-audio', 'post-format-video'),
'operator' => 'NOT IN'
)
)
);
$popular = get_posts($args);
$output = '';
foreach($popular as $post){
setup_postdata($post);
$excerpt = get_the_excerpt($post->ID);
$attachment_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium' );
$url = $attachment_url['0'];
$image = aq_resize($url, 120, 120, true);
$output .= '- ';
if ( has_post_thumbnail($post->ID) ){
$output .= '';
$output .= '
';
$output .= '';
}
$output .= '';
$output .= ' ';
}
$output .= '
';
return $output;
}
add_shortcode('popular_posts', 'shortcode_popular_posts');
//Recent Testimonials
function shortcode_recenttesti($atts, $content = null) {
extract(shortcode_atts(array(
'num' => '5',
'thumb' => 'true',
'excerpt_count' => '30'
), $atts));
$testi = get_posts('post_type=testi&orderby=post_date&numberposts='.$num);
$output = '';
global $post;
global $my_string_limit_words;
foreach($testi as $post){
setup_postdata($post);
$excerpt = get_the_excerpt($post->ID);
$custom = get_post_custom($post->ID);
$testiname = $custom["my_testi_caption"][0];
$testiurl = $custom["my_testi_url"][0];
$testiinfo = $custom["my_testi_info"][0];
$attachment_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
$url = $attachment_url['0'];
$image = aq_resize($url, 60, 60, true);
$output .= '
';
$output .= '
';
if ($thumb == 'true') {
if ( has_post_thumbnail($post->ID) ){
$output .= '';
$output .= '
';
$output .= '';
}
}
$output .= '
';
$output .= '
';
$output .= '
';
}
$output .= '
';
return $output;
}
add_shortcode('recenttesti', 'shortcode_recenttesti');
//Categories
function shortcode_list_categories($atts, $content = null) {
extract(shortcode_atts(array(
'title' => '',
'orderby' => '',
'order' => '',
'exclude' => '',
'include' => '',
'number' => '',
'hide_empty' => '',
'custom_class' => ''
), $atts));
$categories = get_categories('exclude=' . $exclude . '&include=' . $include . '&number=' . $number . '&orderby=' . $orderby . '&order=' . $order . '&hide_empty=' . $hide_empty);
$output = '';
if( !empty($title) || $title != ''){
$output .= '' . $title . '
';
}
$output .= '';
return $output ;
}
add_shortcode('list_categories', 'shortcode_list_categories');
//Tag Cloud
function shortcode_tags($atts, $content = null) {
$output = '';
$tags = wp_tag_cloud('smallest=8&largest=8&format=array');
foreach($tags as $tag){
$output .= $tag.' ';
}
$output .= '
';
return $output;
}
add_shortcode('tags', 'shortcode_tags');
// Audio Player
function shortcode_audio($atts, $content = null) {
extract(shortcode_atts(array(
'file' => '',
'desc' => ''
), $atts));
$template_url = get_template_directory_uri();
$id = mt_rand();
$mp3 = strpos($file, ".mp3");
$output = '